package com.building.controller;

import com.building.common.R;
import com.building.controller.BaseController.BaseController;
import com.building.entity.EngineeringStage;
import com.building.entity.Shopping;
import com.building.enums.REnum;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.web.bind.annotation.*;

/**
 * @author yinjiahui
 * @create 2021-04-15 17:31
 */
@RestController
@RequestMapping("engineeringStage")
public class EngineeringStageController extends BaseController {


    /**
     *  查询所有的项目工程阶段
     * @return
     */
    @GetMapping("selectEngineeringStage")
    @ApiResponses({
            @ApiResponse(code=400,message="请求参数没填好"),
            @ApiResponse(code=404,message="请求路径没有或页面跳转路径不对")
    })
    public R selectEngineeringStage(){
        return R.result(REnum.SUCCESS_QUERY,this.engineeringStageService.selectEngineeringStage());
    }


    /**
     *
     * 根据项目工程阶段id删除
     *
     * @param engineeringStageId
     * @return
     */
    @DeleteMapping("deleteEngineeringStageByEngineeringStageId/{engineeringStageId}")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="根据项目工程阶段id删除",name="engineeringStageId",dataType="Integer",required=true,value="项目工程阶段id",defaultValue="这个是默认值，可以不写"),
    })
    @ApiResponses({
            @ApiResponse(code=400,message="请求参数没填好"),
            @ApiResponse(code=404,message="请求路径没有或页面跳转路径不对")
    })
    public R deleteEngineeringStageByEngineeringStageId(@PathVariable("engineeringStageId") Integer engineeringStageId){
        this.engineeringStageService.deleteEngineeringStageByEngineeringStageId(engineeringStageId);
        return R.result(REnum.SUCCESS_DELETE);
    }

    /**
     *
     * 新增或修改项目工程阶段
     *
     * @param engineeringStage
     * @return
     */
    @PostMapping("insertOrUpdateEngineeringStage")
    @ApiResponses({
            @ApiResponse(code=400,message="请求参数没填好"),
            @ApiResponse(code=404,message="请求路径没有或页面跳转路径不对")
    })
    public R insertOrUpdateEngineeringStage(@RequestBody EngineeringStage engineeringStage){
        return this.engineeringStageService.insertOrUpdateEngineeringStage(engineeringStage);
    }



}
